<%@page import="com.mto.module.karaoke.service.UserSongsLocalServiceUtil"%>
<%@page import="com.liferay.portal.service.UserLocalServiceUtil"%>
<%@page import="com.liferay.portal.model.User"%>
<%@ include file="/jsps/main.jsp"%>

<%
String orderByCol = ParamUtil.getString(request, "orderByCol", "createDate");
String orderByType = ParamUtil.getString(request, "orderByType", "asc").toLowerCase();

UserSongs searchUserSongs = new UserSongsImpl();

PortletURL nameSearchUrl = renderResponse.createRenderURL();
nameSearchUrl.setParameter("jspPage", "/jsps/san-khau/view.jsp");
nameSearchUrl.setParameter("tab", "san-khau");
nameSearchUrl.setPortletMode(PortletMode.VIEW);

PortletURL playUrl = renderResponse.createRenderURL();
playUrl.setParameter("jspPage", "/jsps/san-khau/play.jsp");
playUrl.setParameter("tab", "san-khau");
playUrl.setPortletMode(PortletMode.VIEW);

PortletURL recordUrl = renderResponse.createRenderURL();
recordUrl.setParameter("jspPage", "/jsps/phong-thu/record.jsp");
recordUrl.setParameter("tab", "phong-thu");
recordUrl.setPortletMode(PortletMode.VIEW);
%>

<%
PortletURL renderUrl = renderResponse.createRenderURL();
renderUrl.setParameter("tab", "phong-thu");

PortletURL sortUrl = renderResponse.createRenderURL();
sortUrl.setParameter("tab", "phong-thu");
sortUrl.setParameter("jspPage", "/jsps/phong-thu/view.jsp");
sortUrl.setParameter("orderByType", "asc".equals(orderByType) ? "desc" : "asc");
%>

<div class="corTop04">
			<h2 class="headerTitle"><liferay-ui:message key="newSongRecordings"/></h2>			
</div>
<ul id="karaoke-grid">
<liferay-ui:search-container emptyResultsMessage="no-song-found" delta="<%=10 %>" orderByCol="<%=orderByCol %>" orderByType="<%=orderByType %>" iteratorURL="<%=tab0Url%>">
	<liferay-ui:search-container-results>
		<%
		results = UserSongsServiceUtil.search(searchUserSongs, searchContainer.getStart(), searchContainer.getEnd(), orderByCol, orderByType);
		results = ListUtil.copy(results);
		total = UserSongsServiceUtil.searchCount(searchUserSongs);
		
		pageContext.setAttribute("results", results);
		pageContext.setAttribute("total", total);
		%>
	</liferay-ui:search-container-results>
	
	<liferay-ui:search-container-row className="com.mto.module.karaoke.model.UserSongs" modelVar="userSongs" keyProperty="userSongId">
		<%
		Song song = SongServiceUtil.getSong(userSongs.getSongId());
		User shower = UserLocalServiceUtil.getUser(userSongs.getUserId());
		String songId = String.valueOf(userSongs.getSongId());
		renderUrl.setParameter("songId", songId);
		playUrl.setParameter("userSongsId", String.valueOf(userSongs.getUserSongId()));
		recordUrl.setParameter("songId", songId);
		%>
		<li>
			<div class="box">
				<div class="box-info">
					<div>
						<img alt="" src="<%= imgPath + "icon_notnhac.gif"%>">
						<span class="text" title="<%=song.getSongName() %>">
							<a href="<%= recordUrl.toString()%>"><%=song.getSongName() %></a>
						</span>
					</div>
					<div>
						<span class="label"><%=shower.getScreenName() %></span>						
					</div>
					<div class="sound">
						<a href="<%= playUrl.toString()%>"><img alt="" src="<%= imgPath + "icon_loa.gif"%>" title="Bai thu truc tuyen"> </a>
					</div>
				</div>
				<div style="clear: both;"></div>
			</div>
		</li>
	</liferay-ui:search-container-row>
</liferay-ui:search-container>
</ul>
<div style="clear: both;"></div>
<div class="box-link">			
			<img src="<%= imgPath + "icon_xemthem.gif"%>" align="absmiddle">
			 <a href="<%=nameSearchUrl%>"><liferay-ui:message key="xem-them"/></a>
</div>


<div class="corTop04">
			<h2 class="headerTitle"><liferay-ui:message key="hotSongRecordings"/></h2>			
</div>
<ul id="karaoke-grid">
<liferay-ui:search-container emptyResultsMessage="no-song-found" delta="<%=10 %>" orderByCol="<%=orderByCol %>" orderByType="<%=orderByType %>" iteratorURL="<%=tab0Url%>">
	<liferay-ui:search-container-results>
		<%
		results = UserSongsServiceUtil.search(searchUserSongs, searchContainer.getStart(), searchContainer.getEnd(), orderByCol, orderByType);
		results = ListUtil.copy(results);
		total = UserSongsServiceUtil.searchCount(searchUserSongs);
		
		pageContext.setAttribute("results", results);
		pageContext.setAttribute("total", total);
		%>
	</liferay-ui:search-container-results>
	
	<liferay-ui:search-container-row className="com.mto.module.karaoke.model.UserSongs" modelVar="userSongs" keyProperty="userSongId">
		<%
		Song song = SongServiceUtil.getSong(userSongs.getSongId());
		User shower = UserLocalServiceUtil.getUser(userSongs.getUserId());
		String songId = String.valueOf(userSongs.getSongId());
		renderUrl.setParameter("songId", songId);
		playUrl.setParameter("userSongsId", String.valueOf(userSongs.getUserSongId()));
		recordUrl.setParameter("songId", songId);
		%>
		<li>
			<div class="box">
				<div class="box-info">
					<div>
						<img alt="" src="<%= imgPath + "icon_notnhac.gif"%>">
						<span class="text" title="<%=song.getSongName() %>">
							<a href="<%= recordUrl.toString()%>"><%=song.getSongName() %></a>
						</span>
					</div>
					<div>
						<span class="label"><%=shower.getScreenName() %></span>						
					</div>
					<div class="sound">
						<a href="<%= playUrl.toString()%>"><img alt="" src="<%= imgPath + "icon_loa.gif"%>" title="Bai thu truc tuyen"> </a>
					</div>
				</div>
				<div style="clear: both;"></div>
			</div>
		</li>
	</liferay-ui:search-container-row>
</liferay-ui:search-container>
</ul>
<div style="clear: both;"></div>
<div class="box-link">			
			<img src="<%= imgPath + "icon_xemthem.gif"%>" align="absmiddle">
			 <a href="<%=nameSearchUrl%>"><liferay-ui:message key="xem-them"/></a>
</div>
